Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows empty string for targeting special MethodType options and doesn't try searching for it with AccessTools #622

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

Banane9
Copy link
Contributor

@Banane9 Banane9 commented Aug 30, 2024

Allows patch attributes like [HarmonyPatch(typeof(TargetType), "", MethodType.Getter)] on a method, or

[HarmonyPatch(typeof(TargetType))]
static class PatchClass
{
    [HarmonyPatch("", MethodType.Getter)]
    static void Postfix() { }
}

to target an Indexer for example. With just null instead of "", the second example would be ambiguous.

This may allow making the targeting "nameless" members like (static) constructors or indexers more explicit, by allowing to provide an empty string in addition to the MethodType or null. Now that I'm writing this, it seems almost unnecessary, but the idea came while talking about possible Analyzers for HarmonyPatch attributes

For the AccessTools methods, it checks for empty string as well, as there can't be members with that name. Not with whitespace either, but net3.5 doesn't have that method.

@pardeike
Copy link
Owner

I get the idea and it seems reasonable to have it that way. Can you just clean up the diff at the end where there are empty line changes and also unnecessary “private”? I’ll pull it after that.

@Banane9
Copy link
Contributor Author

Banane9 commented Nov 16, 2024

Ah, that was probably some auto-formatting, although I toggled it off 🤔

Won't be home again until Monday, so if you want to merge it immediately you can edit it too. At least that's toggled on, never used that feature myself before.

@Banane9 Banane9 force-pushed the allow-empty-for-special-targets branch from b7ba4b4 to 2a932b7 Compare December 17, 2024 20:46
@Banane9
Copy link
Contributor Author

Banane9 commented Dec 17, 2024

Okay, completely forgot about this, but here you finally go :D

@pardeike
Copy link
Owner

Would you mind pushing an update that solves the conflict from your last PR?

@Banane9 Banane9 force-pushed the allow-empty-for-special-targets branch from 2a932b7 to 0b13d7b Compare December 18, 2024 09:16
@Banane9
Copy link
Contributor Author

Banane9 commented Dec 18, 2024

Would you mind pushing an update that solves the conflict from your last PR?

Done 👍

@pardeike pardeike merged commit 87ea840 into pardeike:master Dec 18, 2024
23 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants